<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>个人存款计算器</title>
		<link rel="stylesheet" type="text/x-icon" href="img/logo.png">
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/bootstrap.min.js"></script>
		<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
		<script>
			function calc(){
				num1=$("#num1").val();
				regExp=/^[0-9]{1,8}$/
				number1=parseInt(num1);
				// 转换函数
				if(!regExp.test(num1)){
					$("#num1").val("必须是1-8位数字！").css("color","red");
					return;
				}
				year=$("#year option:selected").text();
				if(year=="三年"){
					num2=$("#year").val() * number1 * 3;
				}
				if(year=="四年"){
					num2=$("#year").val() * number1 * 4;
				}
				
				if(year=="两年"){
					num2=$("#year").val() * number1 * 2;
				}
				if(year=="一年"){
					num2=$("#year").val() * number1;
				}
				
				// year=$("#year").val();
				// num2=number1*year;
				$("#num2").val(num2);
				total=number1+num2;
				$("#num3").val(total);
				// alert($("#year option:selected").text());
			}
			function clearNum1(){
				$("#num1").val().css("color","");
			}
		</script>
	</head>
	<body>
		<div style="width: 50%;" class="text-center center-block">
			<img src="img/cmb.png" alt="">
			<table class="table table-bordered">
		</div>
			<tr class="bg-primary">
				<td colspan="2">个人存款计算</td>
				<!-- 合并两个单元格 -->
			</tr>
			<tr>
				<td class="text-right">存款金额</td>
				<td>
					<input onfocus="clearNum1()" class="form-control" type="text" id="num1">
				</td>
			</tr>
			<tr>
				<td>存款期限</td>
				<td class="num1">
					<select class="form-control" id="year">
						<option value="0.0175">一年</option>
						<option value="0.0225">两年</option>
						<option value="0.0275">三年</option>
						<option value="0.0275">四年</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>所得利息</td>
				<td class="num2">
					<input readonly="readonly" class="form-control" type="" name="" id="num2" value="" />
				</td>
			</tr>
			<tr>
				<td>本息合计</td>
				<td class="num3">
					<input readonly="readonly" class="form-control" type="" name="" id="num3" value="" />
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<button onclick="calc()" class="btn btn-primary btn-block">开始计算</button>
				</td>
			</tr>
		</table>
		<div>
			开发者：182055220 李林茹
		</div>
	</body>
</html>
